Hệ thống quản lý ngân hàng máu trong php

1 <?php
2 $i =
0;
3 require_once
'php/DBConnect.php';
4 $db =
new DBConnect();
5 $db->auth();

6 // Search
by Blood Group
7 if
(isset($_POST['searchBtn'])) {
8     $bloodGroup = $_POST[
'blood_group'];
9     $donors = $db->searchDonorWithBloodGroup($bloodGroup);
10 }

11 //Search By City

12 if
(isset($_POST['searchByCityBtn'])) {
13     $city = $_POST[
'city'];
14     $donors = $db->searchDonorByCity($city);
15 }
16 $title =
"Home";
17 $setHomeActive =
"active";
18 include
'layout/_header.php';
19
20 include
'layout/_top_nav.php';
21 ?>
22 <div
class="container">
23     <div
class="row">
24         <div
class="col-md-3"></div>
25         <div
class="col-md-6">
26             <div
class="form-group col-md-12">
27                 <form
class="form-horizontal" method="post" action="home.php">
28                     <div
class="form-group">
29                         <label
class="col-sm-6">Search for donor with blood group </label>
30                         <div
class="col-sm-4">
31                             <
select name="blood_group" class="form-control">
32                                 <option
value="O+">O+</option>
33                                 <option
value="O-">O-</option>
34                                 <option
value="A+">A+</option>
35                                 <option
value="A-">A-</option>
36                                 <option
value="B+">B+</option>
37                                 <option
value="B-">B-</option>
38                                 <option
value="AB+">AB+</option>
39                                 <option
value="AB-">AB-</option>
40                             </
select>
41                         </div>
42                         <div
class="col-sm-2">
43                             <button
class="btn btn-info btn-sm" name="searchBtn" >Search</button>
44                         </div>
45                     </div>
46
47                 </form>
48                 <form
class="form-horizontal" method="post" action="home.php">
49                     <div
class="form-group">
50                         <label
class="col-sm-6">Search for donor by city </label>
51                         <div
class="col-sm-4">
52                             <input type=
"text" name="city" value="" required="true" class="form-control"/>
53                         </div>
54                         <div
class="col-sm-2">
55                             <button
class="btn btn-info btn-sm" name="searchByCityBtn" >Search</button>
56                         </div>
57                     </div>
58
59                 </form>
60             </div>
61         </div>
62         <div
class="col-md-3"></div>
63     </div>
64
65     <div
class="row">
66         <div
class="col-md-1">
67         </div>
68         <div
class="col-md-10">
69             <!-- If the donor
is searched by a particular blood group -->
70             <?php
if(isset($_POST['searchBtn'])): ?>
71                 <?php
if(isset($donors[0])): ?>
72                     <label>Total Blood Units Available
for <?= $donors[0]['b_type']; ?>:</label> <span class="emphasize"><?= count($donors); ?> Unit</span>
73                 <?php endif; ?>
74             <?php endif; ?>
75             
76             <!-- If the donor
is search by a particular City -->
77             <?php
if(isset($_POST['searchByCityBtn'])): ?>
78                 <?php
if(isset($donors[0])): ?>
79                     <label>Total Number of Donors
in this City:</label> <span class="emphasize"><?= count($donors); ?></span>
80                 <?php endif; ?>
81             <?php endif; ?>
82             
83             <!--
if result has been fetched succesffully -->
84             <?php
if (isset($donors)): ?>
85                 <table
class="table table-condensed">
86                     <tr>
87                         <th>Index</th>
88                         <th>Name</th>
89                         <th>Gender</th>
90                         <th>Address</th>
91                         <th>City</th>
92                         <th>Mobile</th>
93                         <th>Phone</th>
94                         <th>Blood Group</th>
95                     <tr>
96                         <?php
foreach ($donors as $d): $i++; ?>
97                         <tr
class="<?php
98                         
if ($i % 2 == 0) {
99                             echo "
bg-success";
100                         }
else {
101                             echo "
bg-danger";
102                         }
103                         ?>"
>
104                             <td><?= $i; ?></td>
105                             <td><a href=
"profile.php?id=<?= $d['id']; ?>"><?= $d['fname'] . " " . $d['mname'] . " " . $d['lname']; ?></a></td>
106                             <td><?= $d[
'sex']; ?></td>
107                             <td><?= wordwrap($d[
'h_address'], 20, "<br>"); ?></td>
108                             <td><?= $d[
'city']; ?></td>
109                             <td><?= $d[
'mobile']; ?></td>
110                             <td><?= $d[
'phone']; ?></td>
111                             <td><?= $d[
'b_type']; ?></td>
112                         </tr>
113                     <?php endforeach; ?>
114                 </table>
115             <?php endif; ?>
116         </div>
117         <div
class="col-md-1"></div>
118     </div>
119 </div>
120 <?php include
'layout/_footer.php'; ?>


Gõ tìm kiếm nhanh...